package com.moes.beta.activity;

import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.StrictMode;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.moes.beta.R;

public class MoesMainActivity extends Activity  {
	 private static final String TAG = "HoneyCombAndroideBook";
	    private Resources resources;
	    private Properties properties = new Properties();
	    private Handler mHandler = new Handler();
	    private ImageView bgImage;

	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);

	        setContentView(R.layout.honeycomb_splash);
	        bgImage = (ImageView) findViewById(R.id.bg_img);
	        initBkgrdImg();

	        resources = this.getResources();
	  
	        RelativeLayout relativeLayout1 = (RelativeLayout) findViewById(R.id.relativeLayout1);
	        AlphaAnimation animation = new AlphaAnimation(0.2f, 1.0f);
	        animation.setDuration(2000);
	        relativeLayout1.startAnimation(animation);
	        Timer showingTimer = new Timer(true);

	        String logOut;
	        Intent intent = this.getIntent();
	        if (intent != null) {
	            Bundle bundle = intent.getExtras();
	            if (bundle != null) {
	                logOut = bundle.getString("Info");
	                if (logOut.equals("1")) {
	                    showingTimer.schedule(showingTask, 0, 500);
	                }
	            } else {
	                showingTimer.schedule(showingTask,1000, 500);
	            }
	        }
	        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
	                .detectNetwork() // or .detectAll() for all detectable problems
	                .penaltyLog().build());
	    }

	    private final TimerTask showingTask = new TimerTask() {
	        @Override
	        public void run() {
	            mHandler.post(new Thread() {
	                public void run() {
	                    new HoneyCombLoginWin(MoesMainActivity.this).show();
	                }
	            });
	            this.cancel();
	        }
	    };

	    private void initBkgrdImg() {
	            bgImage.setImageResource(R.drawable.background);
	      
	    }

	
	
}
